const calculateAge = (idNumber: string) => {
    const currentDate = new Date();
    const currentYear = currentDate.getFullYear();

    const reg = /^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})(\d|X)$/;
    const match = idNumber.match(reg);
    if (!match) {
        return "";
    }

    const year = match[2];
    const age = currentYear - parseInt(year);

    return age;
}
export default calculateAge;